package com.adv.ems.model.vo;

import com.adv.ems.db.entity.BuildingInfoDO;
import com.adv.ems.db.entity.BuildingTypeInfoDO;
import com.adv.ems.db.entity.InstituteInfoDO;
import com.adv.ems.utils.EmsUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.List;

@Data
public class BaseBuildingVO {
    private List<Info> list;

    public BaseBuildingVO() {
        this.list = new ArrayList<Info>();
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Info extends BuildingInfoDO {
        private java.lang.String instituteName;
        private java.lang.String buildingTypeName;

        public Info(BuildingInfoDO building, InstituteInfoDO institute, BuildingTypeInfoDO buildingType, String acceptLanguage) {
            BeanUtils.copyProperties(building, this);
            if (institute != null) {
                this.instituteName = EmsUtil.getNameInfo(institute.getNameInfo(), acceptLanguage).getShortName();
            }
            if (buildingType != null) {
                this.buildingTypeName = buildingType.getName();
            }
        }
    }
}
